import java.util.Vector;

/**
 * This is the given Bank class code fro the project.
 * @author Kristopher Gooding/Kyle Scharnhorst
 * @version 4/25/2014
 */
public class Bank {
	
	/**Name of the owner of the account.*/
	private String my_name;
	/**List of all the checking accounts in the bank.*/
	private Vector<CheckingAccount> my_checking_accounts;
	/**list of all the savings accounts in the bank.*/
	private Vector<SavingsAccount> my_saving_accounts;

	/**
	 * Bank contructor.
	 * @param the_name
	 */
	public Bank(final String the_name) {
		my_name = the_name;
		my_checking_accounts = new Vector<CheckingAccount>();
		my_saving_accounts = new Vector<SavingsAccount>();
	}

	/**
	 * Method to create a new simple checking account.
	 * @return
	 */
	public int openSimpleCheckingAccount() {
		CheckingAccount newAccount = new CheckingAccount("Bob Smith",
				"1 Main St.", "12345", "Tacoma", "USA");
		my_checking_accounts.add(newAccount);
		return newAccount.getAccountNumber();
	}

	/**
	 * Method to open a full account.
	 * @return the new account number for the new account.
	 */
	public int openFullPackage() {
		CheckingAccount newAccount = new CheckingAccount("Bob Smith",
				"1 Main St.", "12345", "Tacoma", "USA");
		my_checking_accounts.add(newAccount);
		newAccount.applyForCreditCard("Bob Smith", "1 Main St.", "12345",
				"Tacoma", "USA", newAccount.getAccountNumber());
		SavingsAccount newSavingsAccount = new SavingsAccount("Bob Smith",
				"1 Main St.", "12345", "Tacoma", "USA");
		my_saving_accounts.add(newSavingsAccount);
		DebitCard newDebetCard = new DebitCard("Bob Smith", "1 Main St.",
				"12345", "Tacoma", "USA", 0, newAccount);
		return newAccount.getAccountNumber();
	}

	/**
	 * method to withdraw money from a specific account.
	 * @param the_account_number
	 * @param the_amount
	 * @return boolean for successful withdraw.
	 */
	public boolean withdrawMoney(final int the_account_number,
			final double the_amount) {
		CheckingAccount account = new CheckingAccount(the_account_number);
		int index = my_checking_accounts.indexOf(account);
		return my_checking_accounts.elementAt(index).withdrawal(the_amount);
	}

	/**
	 * @return the my_name.
	 */
	public String getName() {
		return my_name;
	}

	/**
	 * @return the my_checking_accounts.
	 */
	public Vector<CheckingAccount> getfCheckingAccounts() {
		return my_checking_accounts;
	}

	/**
	 * @return the my_saving_accounts.
	 */
	public Vector<SavingsAccount> getfSavingAccounts() {
		return my_saving_accounts;
	}

}
